package com.sunfeng.chap2.p13;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * @Author : 孙峰
 * @Description:  独占锁 别人是不可以写的
 * @Date : 2021/10/9  16:54
 */
public class Test13_13 {
    public static void main(String[] args) throws IOException, InterruptedException {
        RandomAccessFile randomAccessFile = new RandomAccessFile("d:\\nio\\d.txt", "rw");
        FileChannel fileChannel = randomAccessFile.getChannel();
        fileChannel.lock(1, 2, false);
        Thread.sleep(Integer.MAX_VALUE);
    }
}
